#include "stdafx.h"
#include <sstream>
#include "detail/bmock_func_spec.hpp"

namespace bmock {
	func_spec::func_spec()
	{}

	func_spec::func_spec(const std::string &fn,const location &loc) 
	{
		*this = func_spec("void", fn, loc);
	}

	func_spec::func_spec(const std::string &ret_type,const std::string &fn,const location &loc)
		: name_(fn), loc_(loc)
	{
		expect_ = (ret_type == "void") ? 
			"BMOCK_EXPECT_STR(" : 
			"BMOCK_EXPECT_RETURN_STR(" + ret_type + ',';
	}

	std::string func_spec::message(const arg_list &args) const {
		std::ostringstream os;

		os << expect_ 
			<< name_ 
			<< "," << loc_
			<< "," << args.size()
			<< ",("
			<< boost::lexical_cast<std::string>(args)
			<< "));";			
		return os.str();
	}

	bool func_spec::operator == (const func_spec &fd) const {
		return loc_==fd.loc_;
	}

	std::string func_spec::name() const {
		return name_;
	}
	location func_spec::get_loc()const{
		return loc_;
	}

	bool func_spec::is_void() const {
		return (expect_ == "BMOCK_EXPECT_STR(");
	}
}